new Vue({
	el: '#main',
	data: {
		image: [{"src":'../../img/active/img@3x.png'},{"src":'../../img/active/img@3x.png'},{"src":'../../img/active/img@3x.png'}],
		name:"",
		phone:"",
		files:[],
		currentWebview:''
	},
	methods: {
		plusReady: function() {
			this.currentWebview = plus.webview.currentWebview();
		},
		choiceImgFunc:function(item,index){
			var context = this;
//			this.activeIndex = index;
			var btnArray = [{
				title: "拍照"
			}, {
				title: "从相册选择"
			}];
			plus.nativeUI.actionSheet({
				title: "选择照片",
				cancel: "取消",
				buttons: btnArray
			}, function(e) {
				var index = e.index;
				switch(index) {
					case 0:
						break;
					case 1: //拍照，返回一个相对路径
						var cmr = plus.camera.getCamera();
						cmr.captureImage(function(p) {
							//把相对路径转为绝对路径，
							plus.io.resolveLocalFileSystemURL(p, function(entry) {
								entry.toLocalURL();
								item.src = entry.toLocalURL();
								context.files.push(entry.toLocalURL())
							}, function(e) {

							});

						}, function(e) {

						});
						break;
					case 2: //相册
						plus.gallery.pick(function(path) {
							plus.io.resolveLocalFileSystemURL(path, function(entry) {
								entry.toLocalURL();
								item.src = entry.toLocalURL();
								context.files.push(entry.toLocalURL())
							}, function(e) {

							});
						}, function(err) {

						}, { filter: "image" });
						break;
				}
			});

		},
		submit: function() {
			if(!this.name){
				mui.toast("请输入姓名");
				return
			};
			if(!this.phone){
				mui.toast("请输入手机号");
				return
			};
			if(!isTelPhone(this.phone)){
				mui.toast("请输入正确的手机号");
				return
			};
			if(this.image.length==0){
				mui.toast("请上传报名材料");
				return
			};
			var  context=this;
			var datajson = {
//				meetingId:this.currentWebview.id,
				meetingId:'50edf050a7964711b0d57dd96b5bc3e4',
				image:this.files
			};
			alert(JSON.stringify(datajson))
			ajAjax("app/meeting/indivApply.do", datajson, function(data) {
				mui.toast('报名成功')
			}, function(err) {
				mui.toast('报名失败')
			});
		},
		cancle:function(){
			var datajson = {
				meetingId:'50edf050a7964711b0d57dd96b5bc3e4',
				image:this.files
			};
			ajAjax("app/meeting/deleteIndivApply.do", datajson, function(data) {
				mui.toast('取消报名成功')
			}, function(err) {
				mui.toast('取消报名失败')
			});
		}
	},
	mounted: function() {
		if(window.plus) {
			this.plusReady();
		} else {
			document.addEventListener("plusready", this.plusReady, false);
		}
	}
});